package com.md.mainpage.utils

import android.app.Activity
import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager
import com.md.network.api.Album
import com.md.network.api.Audio


object Utils {

    fun hideSoftKeyboard(context: Context, list:List<View>){
        if (list.isEmpty()) return
        var inputMethodManager = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
        list.forEach {
            inputMethodManager.hideSoftInputFromWindow(it.windowToken, InputMethodManager.HIDE_NOT_ALWAYS)
        }

    }

    fun fillAudioData(album: Album){
        album.audios?.let {
            for (item in it){
                item.albumId = album.id
                item.albumName = album.name
                item.author = album.author
            }
        }
    }

    fun  fillAudioData(album: Album, audios: List<Audio>){
        audios.let {
            for (item in it){
                item.albumId = album.id
                item.albumName = album.name
                item.author = album.author
            }
        }
    }

}